const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    listData:[],
    page: 1,
    finished: false,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getData();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    this.getData();
  },
  getData () {
    if (this.data.finished) return;
    let baseUrl = app.getNetAddresss("plugin.stock-service.frontend.controllers.statement.index");
    app._getNetWork({
      url: baseUrl,
      data: {
        page: this.data.page,
      },
      success: (respone) => {
        if (respone.data.result !== 1) {
          wx.showToast({
            title: respone.data.msg,
          });
          return false;
        }
        let res = respone.data.data;
        let finished = false;
        let listData = [];
        if (res.list.data.length === 0 || res.list.data.length < res.list.per_page || res.list.current_page === res.list.last_page) {
          finished = true;
        }
        listData = this.data.listData.concat(res.list.data);
        this.setData({
          finished,
          listData,
          page: ++this.data.page,
        });
      }
    });
  },
})